/**
 * 资源编号页面数据获取
 * @author 陈涛
 * @date 2019-1-17
 */
import request from '@/api/ResourceNumber/ResourceNumber'
import * as type from '@/store/Mutation/index'

const state = {
  header: [],
  body: {}
}

const getters = {}

const mutations = {
  // 获取资源编号头部
  [type.RESOURCE_HEADER] (state, header) {
    state.header = header.header
  },
  // 获取资源编号表格数据
  [type.RESOURCE_BODY] (state, body) {
    state.body = body.content
  }
}

const actions = {
  /**
   * @author 陈涛
   * @information 获取资源编号头部数据
   * @date 2019-1-17
   */
  // 获取资源编号头部
  getResourceNumberInfoHeader ({ commit }) {
    request.getResourceNumberInfoHeader().then(res => {
      commit(type.RESOURCE_HEADER, res.data.data)
    })
  },
  /**
   * @author 陈涛
   * @information 获取资源编号表格数据
   * @date 2019-1-17
   */
  // 获取资源编号表格数据
  getResourceNumberInfoBody ({ commit }) {
    request.getResourceNumberInfoBody().then(res => {
      commit(type.RESOURCE_BODY, res.data.data.body)
    })
  }
}

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}
